package com.snailhd.scheduled;

import com.snailhd.common.util.StringUtil;
import com.snailhd.service.CalcMacdStockDayService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author hd
 * @date 2019-12-18 22:20
 */

@Slf4j
@Component
@JobHandler("stockDayMacdMaintainSchedule")
public class StockDayMacdMaintainSchedule extends IJobHandler {

    @Resource
    CalcMacdStockDayService calcMacdStockDayService;

    @Override
    public ReturnT<String> execute(String args) throws Exception {

        Integer num = 10;
        try {
            if (StringUtils.isNoneBlank(args)){
                num = Integer.parseInt(args);
            }
        } catch (NumberFormatException e) {
            log.error("参数解析异常：{}",args);
        }
        calcMacdStockDayService.calcAndSave(num);
        return SUCCESS;
    }
}
